package org.example.controller;

import org.example.entity.Book;
import org.example.param.BookParam;
import org.example.service.BookService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Map;

@RestController
@RequestMapping("/book")
public class BookController {
    @Resource
    BookService bookService;

    @PostMapping("/save")
    public Map<String, Object> save(Book book) {
        return bookService.save(book);
    }
    @GetMapping("/page")
    public Map<String,Object> page(BookParam param) {
        return bookService.page(param);
    }
    @PostMapping("/disable")
    public Map<String, Object> disable(Book book) {
        return bookService.disable(book);
    }
    @PostMapping("/batch-import")
    public Map<String, Object> batchImport(MultipartFile file) {
        return bookService.importExcel(file);
    }
}
